Remove dependency on Source if we only want a Package
authorCarol (Nichols || Goulding) <carol.nichols@gmail.com>
Sat, 19 Sep 2015 18:07:04 +0000 (14:07 -0400)
committerCarol (Nichols || Goulding) <carol.nichols@gmail.com>
Sun, 20 Sep 2015 03:19:16 +0000 (23:19 -0400)
As alluded to in the previous commit, we don't actually need a Source at
all in order to be able to get a Package given a manifest and a config.

src/cargo/core/package.rs

index 1860257eaf8c70c487a24ab1c90e5b9a64a48133..90c605512c975495fb5537e3e8b100a9bb6abe82 100644 (file)
@@ -4,12 +4,12 @@ use std::slice;
 use std::path::{Path, PathBuf};
 use semver::Version;
 
-use core::{Dependency, Manifest, PackageId, Registry, Target, Summary, Metadata};
+use core::{Dependency, Manifest, PackageId, SourceId, Registry, Target, Summary, Metadata};
+use ops;
 use core::dependency::SerializedDependency;
 use util::{CargoResult, graph, Config};
 use rustc_serialize::{Encoder,Encodable};
 use core::source::Source;
-use sources::PathSource;
 
 /// Informations about a package that is available somewhere in the file system.
 ///
@@ -60,9 +60,11 @@ impl Package {
     }
 
     pub fn for_path(manifest_path: &Path, config: &Config) -> CargoResult<Package> {
-        let mut source = try!(PathSource::for_path(manifest_path.parent().unwrap(),
-                                                   config));
-        source.root_package()
+        let path = manifest_path.parent().unwrap();
+        let source_id = try!(SourceId::for_path(path));
+        let (pkg, _) = try!(ops::read_package(&manifest_path, &source_id,
+                                              config));
+        Ok(pkg)
     }
 
     pub fn dependencies(&self) -> &[Dependency] { self.manifest.dependencies() }